package com.xueyi.workflow.convert;

import com.xueyi.common.core.web.entity.model.BaseConverter;
import com.xueyi.workflow.domain.query.WfProcessVersionQuery;
import com.xueyi.workflow.domain.dto.WfProcessVersionDto;
import com.xueyi.workflow.domain.entity.WfProcessVersion;
import com.xueyi.workflow.convert.PageConverterUtil;
import com.github.pagehelper.Page;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

@Component
public class WfProcessVersionConverter implements BaseConverter<WfProcessVersionQuery, WfProcessVersionDto, WfProcessVersion> {
    @Override
    public WfProcessVersionDto mapperDto(WfProcessVersion po) {
        if (po == null) return null;
        WfProcessVersionDto dto = new WfProcessVersionDto();
        BeanUtils.copyProperties(po, dto);
        return dto;
    }
    @Override
    public List<WfProcessVersionDto> mapperDto(Collection<WfProcessVersion> poList) {
        if (poList == null) return null;
        return poList.stream().map(this::mapperDto).collect(Collectors.toList());
    }
    @Override
    public Page<WfProcessVersionDto> mapperPageDto(Collection<WfProcessVersion> poList) {
        return PageConverterUtil.mapperPageDto(poList, this::mapperDto);
    }
    @Override
    public WfProcessVersion mapperPo(WfProcessVersionDto dto) {
        if (dto == null) return null;
        WfProcessVersion po = new WfProcessVersion();
        BeanUtils.copyProperties(dto, po);
        return po;
    }
    @Override
    public List<WfProcessVersion> mapperPo(Collection<WfProcessVersionDto> dtoList) {
        if (dtoList == null) return null;
        return dtoList.stream().map(this::mapperPo).collect(Collectors.toList());
    }
    @Override
    public Page<WfProcessVersion> mapperPagePo(Collection<WfProcessVersionDto> dtoList) {
        return PageConverterUtil.mapperPagePo(dtoList, this::mapperPo);
    }
} 